<?php

global $footer, $data;

class About extends CI_Controller {

    public function __construct() {
        parent::__construct();
        global $footer, $data;
        if ($this->session->userdata('lang') == 'spanish') {
            $this->lang->load('about', 'spanish');
            $data['prev_noticia'] = $this->ciempies_model->previewNoticiasEs();
            $data['portada'] = $this->ciempies_model->portada('_ES');
            $data['m'] = $this->ciempies_model->responsable(1,'_ES');
            $data['a'] = $this->ciempies_model->responsable(2,'_ES');
            $footer = "footer";
            $data['icon_lang']="en.jpg";
        } else {
            $this->lang->load('about', 'english');
            $data['prev_noticia'] = $this->ciempies_model->previewNoticiasEn();
            $data['portada'] = $this->ciempies_model->portada('_EN');
            $data['m'] = $this->ciempies_model->responsable(1,'_EN');
            $data['a'] = $this->ciempies_model->responsable(2,'_EN');
            $footer = "footer_en";
            $data['icon_lang']="es.jpg";
        }
        $this->cargarIdioma();
        $data['place']="about";
        $this->registrar_visita($data['place']);
    }

    //control de home
    public function index() {
        global $footer, $data;

        $this->load->view('template/front_end/header_about', $data);
        $this->load->view('front_end/about_main');
        $this->load->view('front_end/about_news');
        $this->load->view('template/front_end/' . $footer);
    }

    public function cargarIdioma() {
        global $data;
        /*  traduccion del menú */
        $data['headerTituloNotros'] = $this->lang->line('headerTituloNotros');
        $data['headerTituloDescarg'] = $this->lang->line('headerTituloDescarg');
        $data['headerTituloHerram'] = $this->lang->line('headerTituloHerram');
        $data['headerTituloDocu'] = $this->lang->line('headerTituloDocu');
        $data['headerTituloCol'] = $this->lang->line('headerTituloCol');
        $data['headerTituloNoticias'] = $this->lang->line('headerTituloNoticias');
        $data['headerTituloContcato'] = $this->lang->line('headerTituloContcato');
        /* traduccion de pagina principal */
        $data['aboutNewsTitle'] = $this->lang->line('aboutNewsTitle');
        $data['aboutMainTitle'] = $this->lang->line('aboutMainTitle');
        $data['aboutMainDescription'] = $this->lang->line('aboutMainDescription');
        $data['aboutMainKeep'] = $this->lang->line('aboutMainKeep');
        $data['aboutMainMena'] = $this->lang->line('aboutMainMena');
        $data['aboutMainAbel'] = $this->lang->line('aboutMainAbel');
        $data['aboutMainMenaGrade'] = $this->lang->line('aboutMainMenaGrade');
        $data['aboutMainAbelGrade'] = $this->lang->line('aboutMainAbelGrade');
        $data['aboutMainMailTag'] = $this->lang->line('aboutMainMailTag');
        $data['title'] = $this->lang->line('title');
        $data['aboutNewsBoton'] = $this->lang->line('aboutNewsBoton');

        /* carga de las miniaturas */
        $data['miniPortada1'] = $this->lang->line('miniPortada1');
        $data['miniPortada3'] = $this->lang->line('miniPortada3');
    }
    
        public function lenChg() {
        global $data;
        if ($this->session->userdata('lang') == 'spanish') {
            $this->session->set_userdata('lang', 'english');
        } else {
            $this->session->set_userdata('lang', 'spanish');
        }
        redirect(base_url().$data['place']);
    }
    
    public function registrar_visita($place) {
        $v_sitio="ciempiess.org/$place";
        $v_date=date('Y-m-j H:i:s');
        $v_ip=  $this->input->ip_address();
        $this->ciempies_model->registrar_visita($v_sitio,$v_date,$v_ip);
    }

}
